home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 10.6 KB | 379 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPresen.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWVIEWAS_H
- #include "FWViewAs.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWBNDSTR_H
- #include "FWBndStr.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwpart2
- #endif
-
- FW_DEFINE_CLASS_M0(FW_CPresentation)
-
- //========================================================================================
- // class FW_CPresentation
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::FW_CPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CPresentation::FW_CPresentation(Environment *ev,
- FW_CPart* thePart,
- FW_CSelection* selection,
- ODTypeToken presentationType,
- FW_Boolean sameViewTypeForEmbeddedFrames) :
- fPart(thePart),
- fFrames(NULL),
- fSelection(selection),
- fPresentationType(presentationType),
- fViewInWindowFrame(NULL),
- fViewAsThumbnail(NULL),
- fViewAsSmallIcon(NULL),
- fViewAsLargeIcon(NULL),
- fSameViewTypeForEmbeddedFrames(sameViewTypeForEmbeddedFrames)
- {
- FW_ASSERT(thePart);
-
- fFrames = new FW_CPrivOrderedCollection();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::~FW_CPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CPresentation::~FW_CPresentation()
- {
- FW_ASSERT(fViewAsThumbnail == NULL); // Should already have been released
- FW_ASSERT(fViewAsSmallIcon == NULL);
- FW_ASSERT(fViewAsLargeIcon == NULL);
-
- delete fSelection;
-
- Environment* ev = somGetGlobalEnvironment();
-
- if (fFrames != NULL)
- {
- FW_CFrame* frame = (FW_CFrame*)fFrames->First();
- while (frame != NULL)
- {
- PrivRemoveFrame(ev, frame);
- frame = (FW_CFrame*)fFrames->First();
- }
-
- delete fFrames;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::Invalidate
- //----------------------------------------------------------------------------------------
- // invalidShape should be in content coordinates
-
- void FW_CPresentation::Invalidate(Environment *ev, ODShape* invalidShape, ODFacet* skipFacet)
- {
- FW_CAcquiredODShape aqWrkShape(::FW_NewODShape(ev));
- FW_CPresentationFrameIterator ite(this);
- for (FW_CFrame* frame = ite.First(); ite.IsNotComplete(); frame = ite.Next())
- {
- FW_CAcquiredODTransform aqInternalTransform = frame->AcquireInternalTransform(ev, NULL);
- FW_CFrameFacetIterator facetIte(ev, frame);
- for (ODFacet* facet = facetIte.First(ev); facetIte.IsNotComplete(ev); facet = facetIte.Next(ev))
- {
- if (facet != skipFacet)
- {
- if (invalidShape != NULL)
- {
- aqWrkShape->CopyFrom(ev, invalidShape);
- aqWrkShape->Transform(ev, aqInternalTransform);
- facet->Invalidate(ev, aqWrkShape, NULL);
- }
- else
- {
- FW_CAcquiredODShape aqClipShape = facet->AcquireAggregateClipShape(ev, NULL);
- facet->Invalidate(ev, aqClipShape, NULL);
- }
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::Validate
- //----------------------------------------------------------------------------------------
- // validShape should be in content coordinates
-
- void FW_CPresentation::Validate(Environment *ev, ODShape* validShape, ODFacet* skipFacet)
- {
- FW_CAcquiredODShape aqWrkShape(::FW_NewODShape(ev));
- FW_CPresentationFrameIterator ite(this);
- for (FW_CFrame* frame = ite.First(); ite.IsNotComplete(); frame = ite.Next())
- {
- FW_CAcquiredODTransform aqInternalTransform = frame->AcquireInternalTransform(ev, NULL);
- FW_CFrameFacetIterator iter(ev, frame);
- for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
- {
- if (facet != skipFacet)
- {
- if (validShape != NULL)
- {
- aqWrkShape->CopyFrom(ev, validShape);
- aqWrkShape->Transform(ev, aqInternalTransform);
- facet->Validate(ev, aqWrkShape, NULL);
- }
- else
- {
- FW_CAcquiredODShape aqValidShape = facet->AcquireAggregateClipShape(ev, NULL);
- facet->Validate(ev, aqValidShape, NULL);
- }
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::Invalidate
- //----------------------------------------------------------------------------------------
- // invalidRect should be in content coordinates
-
- void FW_CPresentation::Invalidate(Environment* ev, const FW_CRect& invalidRect, ODFacet* skipFacet)
- {
- FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, invalidRect);
- Invalidate(ev, aqShape, skipFacet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::Validate
- //----------------------------------------------------------------------------------------
- // validRect should be in content coordinates
-
- void FW_CPresentation::Validate(Environment* ev, const FW_CRect& validRect, ODFacet* skipFacet)
- {
- FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, validRect);
- Validate(ev, aqShape, skipFacet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::PrivAddFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CPresentation::PrivAddFrame(Environment *ev, FW_CFrame* frame)
- {
- fFrames->AddLast(frame);
- frame->GetODFrame(ev)->Acquire(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::PrivRemoveFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CPresentation::PrivRemoveFrame(Environment *ev, FW_CFrame* frame)
- {
- if (fViewInWindowFrame == frame)
- fViewInWindowFrame = NULL;
-
- fFrames->Remove(frame);
- frame->PrivReleaseODFrame(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::CountFrame
- //----------------------------------------------------------------------------------------
-
- unsigned long FW_CPresentation::CountFrame(Environment *ev) const
- {
- return fFrames->Count();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::Embed
- //----------------------------------------------------------------------------------------
- // [HLX] need to add exception handling here
-
- void FW_CPresentation::Embed(Environment *ev,
- ODPart *odEmbeddedPart,
- ODFrame* odEmbeddedFrame, // Might be null
- FW_MProxy* proxy,
- ODShape* frameShape,
- ODTypeToken viewType,
- ODTypeToken presentationType,
- ODID frameGroupID,
- FW_Boolean subFrame)
- {
- FW_DEBUG_MESSAGE("FW_CPresentation::Embed Should never have been called");
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::ViewInWindow
- //----------------------------------------------------------------------------------------
-
- ODID FW_CPresentation::ViewInWindow(Environment* ev, FW_CFrame* sourceFrame, ODFacet* sourceFacet)
- {
- FW_ASSERT(sourceFrame);
-
- FW_CWindow* window = NULL;
-
- if (fViewInWindowFrame != NULL)
- {
- window = fViewInWindowFrame->GetWindow(ev);
- }
- else
- {
- if (sourceFacet == NULL)
- {
- FW_CFrameFacetIterator ite(ev, sourceFrame);
- sourceFacet = ite.First(ev);
- }
- FW_ASSERT(sourceFacet != NULL);
-
- window = sourceFrame->NewPartWindow(ev, sourceFacet);
- window->Show(ev); // ATTENTION: Show should be before Select
-
- FW_CAcquiredODWindow odWindow = window->AcquireODWindow(ev);
-
- fViewInWindowFrame = FW_CFrame::ODtoFWFrame(ev, odWindow->GetRootFacet(ev)->GetFrame(ev));
- FW_ASSERT(fViewInWindowFrame != NULL);
- }
-
- window->Select(ev);
-
- return window->GetID(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::AcquireViewAs
- //----------------------------------------------------------------------------------------
-
- FW_CViewAs* FW_CPresentation::AcquireViewAs(Environment* ev, FW_CFrame* frame, ODTypeToken viewAsToken)
- {
- FW_ASSERT(viewAsToken == FW_CPart::gViewAsThumbnailToken ||
- viewAsToken == FW_CPart::gViewAsSmallIconToken ||
- viewAsToken == FW_CPart::gViewAsLargeIconToken);
-
- FW_CViewAs* viewAs = NULL;
- if (viewAsToken == FW_CPart::gViewAsThumbnailToken)
- {
- if (fViewAsThumbnail == NULL)
- fViewAsThumbnail = new FW_CViewAsThumbnail(ev, fPart);
- else
- fViewAsThumbnail->Acquire();
-
- viewAs = fViewAsThumbnail;
- }
- else if (viewAsToken == FW_CPart::gViewAsSmallIconToken)
- {
- if (fViewAsSmallIcon == NULL)
- fViewAsSmallIcon = new FW_CViewAsSmallIcon(ev, fPart);
- else
- fViewAsSmallIcon->Acquire();
-
- viewAs = fViewAsSmallIcon;
- }
- else
- {
- if (fViewAsLargeIcon == NULL)
- fViewAsLargeIcon = new FW_CViewAsLargeIcon(ev, fPart);
- else
- fViewAsLargeIcon->Acquire();
-
- viewAs = fViewAsLargeIcon;
- }
-
- viewAs->Load(ev, frame);
- return viewAs;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPresentation::AcquireViewAs
- //----------------------------------------------------------------------------------------
-
- void FW_CPresentation::ReleaseViewAs(Environment* ev, FW_CViewAs* viewAs)
- {
- FW_ASSERT(viewAs == fViewAsThumbnail || viewAs == fViewAsSmallIcon || viewAs == fViewAsLargeIcon);
-
- if (viewAs->Release() == 0)
- {
- if (viewAs == fViewAsThumbnail)
- fViewAsThumbnail = NULL;
- else if (viewAs == fViewAsSmallIcon)
- fViewAsSmallIcon = NULL;
- else
- fViewAsLargeIcon = NULL;
- }
- }
-